using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Mob))]
[RequireComponent(typeof(SpriteRenderer))]
public class HitFlash:MonoBehaviour {
	void Start() {
		GetComponentReference();
	}
	void Update() {
		if(mob.timeAfterHit<flashTime) spriteRenderer.material=materialFlash;
		else spriteRenderer.material=materialNormal;
	}

	//unity reference
	Mob mob;
	SpriteRenderer spriteRenderer;
	[SerializeField] Material materialNormal;
	[SerializeField] Material materialFlash;
	[SerializeField] float flashTime = 0.1f;

	void GetComponentReference() {
		mob=GetComponent<Mob>();
		spriteRenderer=GetComponent<SpriteRenderer>();
	}


}